Ext.define('NIM.view.AssetDataMaster.AssetNonSacForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.AssetNonSacForm',
    id: 'assetnonsacform',
    method: 'POST',
    url: './Services/Asset/AssetNonSac/Update',
    listeners: {
        afterrender: function () {
            Ext.Ajax.request({
                method: "GET",
                dataType: "json",
                url: "./Services/DataMaster/AdditionalField/List/" + category,
                async: false,
                success: function (c) {
                    var jsonResults = $.parseJSON(c.responseText);
                    Ext.getCmp('addInfNonSacId').add(jsonResults);
                }
            });
        }
    },
    items: [{
            xtype: 'panel',
            border: false,
            width: 690,
            height: 475,
            margin: '0 10 5 10',
            items: [
                {
                    xtype: 'hiddenfield',
//                    cls: 'black',
                    id: 'assetIdNonSac',
                    name: 'ASSET_DETAIL_ID',
                    margin: '5 10 5 25',
                    labelWidth: 100 / 1366 * screen.width,
                    width: 300 / 1366 * screen.width,
                    fieldLabel: 'Asset ID',
                    msgTarget: 'title',
                    allowBlank: true,
                    validateBlank: false
                },
                {
                    xtype: 'hiddenfield',
//                    cls: 'black',
                    id: 'categorynonsac',
                    name: 'CATEGORY',
                    margin: '20 10 5 5',
                    labelWidth: 100 / 1366 * screen.width,
                    width: 300 / 1366 * screen.width,
                    fieldLabel: 'Site ID',
                    msgTarget: 'title',
                    allowBlank: true,
                    validateBlank: false

                },
                {
                    xtype: 'textfield',
//                    cls: 'black',
                    id: 'siteidnonsac',
                    name: 'SITE_ID',
                    margin: '20 10 5 5',
                    labelWidth: 100 / 1366 * screen.width,
                    width: 300 / 1366 * screen.width,
                    fieldLabel: 'Site ID',
                    msgTarget: 'title',
                    allowBlank: true,
                    validateBlank: false

                },
                {
                    xtype: 'combobox',
//                    cls: 'black',
                    id: 'assetcategorynonsac',
                    name: 'CATEGORY_ID',
                    margin: '10 10 5 5',
                    labelWidth: 100 / 1366 * screen.width,
                    width: 650 / 1366 * screen.width,
                    fieldLabel: 'Asset Category',
                    displayField: 'CATEGORY',
                    valueField: 'CATEGORY_ID',
                    emptyText: 'CATEGORY',
                    msgTarget: 'title',
                    queryMode: "local",
                    allowBlank: true,
                    forceSelection: true,
                    store: 'AssetDataMaster.Category',
                    listeners: {
                        change: function (obj, newValue, oldValue, eOpts) {
                            var cat_id = Ext.getCmp("assetcategorynonsac").getValue();
                            Ext.getStore('AssetDataMaster.SubCategory').removeAll();
                            Ext.getStore('AssetDataMaster.SubCategory').getProxy().url = './Services/DataMaster/SubCategory/List?category_id=' + cat_id;
                            Ext.getStore('AssetDataMaster.SubCategory').load();
                        }
                    }
                },
                {
                    xtype: 'textfield',
//                    cls: 'black',
                    id: 'categorydescnonsac',
                    name: 'DESCRIPTION',
                    margin: '10 10 5 5',
                    labelWidth: 100 / 1366 * screen.width,
                    width: 650 / 1366 * screen.width,
                    fieldLabel: 'Description',
                    msgTarget: 'title',
                    allowBlank: true,
                    validateBlank: false

                },
                {
                    xtype: 'panel',
                    border: false,
                    layout: {
                        type: 'table',
                        columns: 2
                    },
                    items: [
                        {
                            xtype: 'panel',
                            width: 345,
                            height: 270,
                            border: false,
                            margin: '0 10 0 0',
                            items: [
                                {
                                    xtype: 'panel',
                                    border: false,
                                    layout: {
                                        type: 'table',
                                        columns: 2
                                    },
                                    items: [
                                        {
                                            xtype: 'combobox',
                                            cls: 'black',
                                            id: 'subcategorynonsac',
                                            name: 'SUB_CATEGORY_ID',
                                            margin: '10 10 5 5',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 280 / 1366 * screen.width,
                                            fieldLabel: 'Sub Category',
                                            displayField: 'SUB_CATEGORY',
                                            valueField: 'SC_ID',
                                            emptyText: 'Sub Category',
                                            msgTarget: 'title',
                                            queryMode: "local",
                                            allowBlank: true,
                                            forceSelection: true,
                                            store: 'AssetDataMaster.SubCategory',
                                            listeners: {
                                                change: function (obj, newValue, oldValue, eOpts) {
                                                    var sc_id = Ext.getCmp("subcategorynonsac").getValue();
                                                    Ext.getStore('AssetDataMaster.Brand').removeAll();
                                                    Ext.getStore('AssetDataMaster.Brand').getProxy().url = './Services/DataMaster/Brand/List?sc_id=' + sc_id;
                                                    Ext.getStore('AssetDataMaster.Brand').load();
                                                }
                                            }
                                        },
                                        {
                                            xtype: 'button',
                                            text: 'Add',
                                            id: 'btnAddSub',
                                            margin: '10 10 5 5',
                                            width: 30,
                                            handler: function () {
                                                Ext.getCmp('maincontent').remove(Ext.getCmp('asset_subcategory_main'));
                                                Ext.create('Ext.window.Window', {
                                                    height: 200,
                                                    width: 370,
                                                    layout: 'fit',
                                                    closable: false,
                                                    modal: true,
                                                    title: 'Add Sub Category',
                                                    items: [
                                                        {
                                                            xtype: 'asset_subcategory',
                                                            title: '',
                                                            collapsed: false,
                                                            collapsible: false,
                                                        }
                                                    ]
                                                }).show();

                                                Ext.getCmp("Category").setValue(Ext.getCmp("assetcategorynonsac").getRawValue());
                                                Ext.getCmp("Category").setDisabled(true);

                                                Ext.getCmp("CategoryId").setValue(Ext.getCmp("assetcategorynonsac").getValue());
                                                Ext.getCmp("ButtonAddBrand").setVisible(false);
                                                Ext.getCmp('ButtonClearSubCategory').setText('Close');
                                            }
                                        }

                                    ]
                                },
                                {
                                    xtype: 'panel',
                                    border: false,
                                    layout: {
                                        type: 'table',
                                        columns: 2
                                    },
                                    items: [
                                        {
                                            xtype: 'combobox',
                                            cls: 'black',
                                            id: 'brandnonsac',
                                            name: 'BRAND_ID',
                                            margin: '10 10 5 5',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 280 / 1366 * screen.width,
                                            fieldLabel: 'Asset Brand',
                                            displayField: 'BRAND',
                                            valueField: 'AB_ID',
                                            emptyText: 'Asset Brand',
                                            msgTarget: 'title',
                                            queryMode: "local",
                                            allowBlank: true,
                                            forceSelection: true,
                                            store: 'AssetDataMaster.Brand',
                                            listeners: {
                                                change: function (obj, newValue, oldValue, eOpts) {
                                                    var ab_id = Ext.getCmp("brandnonsac").getValue();
                                                    Ext.getStore('AssetDataMaster.Type').removeAll();
                                                    Ext.getStore('AssetDataMaster.Type').getProxy().url = './Services/DataMaster/Type/List?ab_id=' + ab_id;
                                                    Ext.getStore('AssetDataMaster.Type').load();
                                                }
                                            }
                                        },
                                        {
                                            xtype: 'button',
                                            text: 'Add',
                                            id: 'btnAddBrand',
                                            margin: '10 10 5 5',
                                            width: 30,
                                            handler: function () {
                                                Ext.getCmp('maincontent').remove(Ext.getCmp('asset_subcategory_main'));
                                                Ext.create('Ext.window.Window', {
                                                    height: 230,
                                                    width: 370,
                                                    layout: 'fit',
                                                    closable: false,
                                                    modal: true,
                                                    title: 'Add Brand',
                                                    items: [
                                                        {
                                                            xtype: 'asset_brand',
                                                            title: '',
                                                            collapsed: false,
                                                            collapsible: false,
                                                        }
                                                    ]
                                                }).show();

                                                Ext.getCmp("categoryBrand").setValue(Ext.getCmp("assetcategorynonsac").getRawValue());
                                                Ext.getCmp("subCategoryBrand").setValue(Ext.getCmp("subcategorynonsac").getRawValue());
                                                Ext.getCmp("categoryBrand").setDisabled(true);
                                                Ext.getCmp("subCategoryBrand").setDisabled(true);

                                                Ext.getCmp("scIdBrand").setValue(Ext.getCmp("subcategorynonsac").getValue());
                                                Ext.getCmp("ButtonAddType").setVisible(false);
                                                Ext.getCmp('ButtonClearBrand').setText('Close');
                                            }
                                        }
                                    ]
                                },
                                {
                                    xtype: 'panel',
                                    border: false,
                                    layout: {
                                        type: 'table',
                                        columns: 2
                                    },
                                    items: [
                                        {
                                            xtype: 'combobox',
                                            cls: 'black',
                                            id: 'typenonsac',
                                            name: 'TYPE_ID',
                                            margin: '10 10 5 5',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 280 / 1366 * screen.width,
                                            fieldLabel: 'Asset Type',
                                            displayField: 'TYPE',
                                            valueField: 'TYPE_ID',
                                            emptyText: 'Asset Type',
                                            msgTarget: 'title',
                                            allowBlank: true,
                                            forceSelection: true,
                                            queryMode: "local",
                                            store: 'AssetDataMaster.Type'
                                        },
                                        {
                                            xtype: 'button',
                                            text: 'Add',
                                            id: 'btnAddType',
                                            margin: '10 10 5 5',
                                            width: 30,
                                            handler: function () {
                                                Ext.getCmp('maincontent').remove(Ext.getCmp('asset_subcategory_main'));
                                                Ext.create('Ext.window.Window', {
                                                    height: 260,
                                                    width: 370,
                                                    layout: 'fit',
                                                    closable: false,
                                                    modal: true,
                                                    title: 'Add Type',
                                                    items: [
                                                        {
                                                            xtype: 'asset_type',
                                                            title: '',
                                                            collapsed: false,
                                                            collapsible: false,
                                                        }
                                                    ]
                                                }).show();

                                                Ext.getCmp("categoryType").setValue(Ext.getCmp("assetcategorynonsac").getRawValue());
                                                Ext.getCmp("subCategoryType").setValue(Ext.getCmp("subcategorynonsac").getRawValue());
                                                Ext.getCmp("brandType").setValue(Ext.getCmp("brandnonsac").getRawValue());
                                                Ext.getCmp("categoryType").setDisabled(true);
                                                Ext.getCmp("subCategoryType").setDisabled(true);
                                                Ext.getCmp("brandType").setDisabled(true);

                                                Ext.getCmp("abIdType").setValue(Ext.getCmp("brandnonsac").getValue());
                                                Ext.getCmp('ButtonClearType').setText('Close');
                                            }
                                        }
                                    ]
                                },
                                {
                                    xtype: 'panel',
                                    border: false,
                                    layout: 'hbox',
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            cls: 'black',
                                            id: 'capacityunitnonsac',
                                            name: 'CAPACITY_UNIT',
                                            margin: '10 10 5 5',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 160 / 1366 * screen.width,
                                            fieldLabel: 'Capacity Unit',
                                            msgTarget: 'title',
                                            allowBlank: true,
                                            validateBlank: false
                                        },
                                        {
                                            xtype: 'textfield',
                                            cls: 'black',
                                            id: 'capacityqtynonsac',
                                            name: 'CAPACITY_QTY',
                                            margin: '10 10 5 0',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 70 / 1366 * screen.width,
                                            msgTarget: 'title',
                                            allowBlank: true,
                                            validateBlank: false
                                        }
                                    ]
                                },
                                {
                                    xtype: 'panel',
                                    border: false,
                                    layout: 'hbox',
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            cls: 'black',
                                            id: 'stockqtynonsac',
                                            name: 'ITEM_QTY',
                                            margin: '10 10 5 5',
                                            labelWidth: 100 / 1366 * screen.width,
                                            width: 160 / 1366 * screen.width,
                                            fieldLabel: 'Stock Items',
                                            msgTarget: 'title',
                                            allowBlank: true,
                                            validateBlank: false
                                        },
                                        {
                                            xtype: 'textfield',
                                            cls: 'black',
                                            id: 'stocksatuannonsac',
                                            name: 'ITEM_UNIT',
                                            margin: '10 10 5 0',
                                            labelWidth: 60 / 1366 * screen.width,
                                            msgTarget: 'title',
                                            allowBlank: true,
                                            validateBlank: false
                                        }
                                        
                                    ]
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'ponononsac',
                                    name: 'PO_NUMBER',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'PO No',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'rcvnonsac',
                                    name: 'RCV_NUMBER',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'RCV No',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                }]
                        },
                        {
                            xtype: 'panel',
                            width: 345,
                            border: false,
                            height: 270,
                            items: [{
                                    xtype: 'combobox',
                                    cls: 'black',
                                    id: 'assettelkomselnonsac',
                                    name: 'ASSET_FLAG',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'Asset Telkomsel',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    forceSelection: true,
                                    store: [['yes', 'Yes'], ['no', 'No']]
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'skunonsac',
                                    name: 'SKU_NUMBER',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'SKU',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'serialnononsac',
                                    name: 'SERIAL_NUMBER',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'Serial Number',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false

                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'partnononsac',
                                    name: 'PART_NUMBER',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'Part Number',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                },
                                {
                                    xtype: 'combobox',
                                    cls: 'black',
                                    id: 'statusnonsac',
                                    name: 'STATUS',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'Status',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    forceSelection: true,
                                    store: [['active', 'Active'], ['inactive', 'Inacvtive']]
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'referencenonsac',
                                    name: 'REFERENCE',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'Reference',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                },
                                {
                                    xtype: 'textfield',
                                    cls: 'black',
                                    id: 'bastnonsac',
                                    name: 'BAST',
                                    margin: '10 10 5 5',
                                    labelWidth: 100 / 1366 * screen.width,
                                    width: 250 / 1366 * screen.width,
                                    fieldLabel: 'BAST',
                                    msgTarget: 'title',
                                    allowBlank: true,
                                    validateBlank: false
                                }]

                        },
                        {
                            xtype: 'panel',
                            layout: 'hbox',
                            colspan: 2,
                            border: false,
                            width: 670,
                            height: 300,
                            items: [
                                {
                                    xtype: 'fieldset',
                                    id: 'addInfNonSacId',
                                    columnWidth: 0.5,
                                    title: 'Additional Information',
                                    width: 320,
                                    margin: '0 10 5 10',
                                },
                                {
                                    xtype: 'button',
                                    text: 'Update',
                                    id: 'btnUpdateNonSac',
                                    waitMsg: 'Processing',
                                    width: 60,
                                    height: 30,
                                    handler: function () {
                                        inputDataNonSac();
                                    }
                                },
                                {
                                    xtype: 'button',
                                    text: 'Cancel',
                                    id: 'btnCancelNonSac',
                                    margin: '0 0 0 10',
                                    width: 60,
                                    height: 30,
                                    handler: function () {
                                        Ext.getCmp('assetMainForm').removeAll(true);
                                        Ext.getCmp('assetMainForm').add({xtype: 'AssetNonSacGrid'});
                                        Ext.getCmp('assetMainForm').doLayout();
                                    }

                                }]


                        }]


                }]

        }]

});